package AuxFunctions;

import GA.Algorithm;

public class Arrays {
	
	public static boolean exists(int index, int[] a) {
		for (int i = 0; i < index; i++)
			if (a[index] == a[i])
				return true;
		return false;
	}
	
	public static void shuffle(int[] a) {
		for (int i=a.length-1; i>=1; i--) {
			int j = Algorithm.random.nextInt(i+1); // un numero entre 0 e i, inclusive
			// intercambia a[i], a[j]
			int aux = a[j];
			a[j] = a[i];
			a[i] = aux;
		}
	}
	
	public static int fact(int n){
		int f = 1;
		while ( n!=0) {
			  f=f*n;
			  n--;
		}
		return f;
	}

}
